import os

def print_formula(formula, filename, res=150):
    f = open('tmp.tex', 'w')
    latex = r"""
\documentclass[12pt]{{article}}
\usepackage{{poine_style}}
\pagestyle{{empty}}
\begin{{document}}
  {:s}
\end{{document}}
""".format(formula)
    f.write(latex)
    f.close()
    os.system("latex tmp.tex")
    os.system("dvipng -D {:d} tmp.dvi -o {:s} -T tight -bg transparent".format(res, filename))
